package com.hanbang.chu_xing_gao_zhao.view_dynamic;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

import com.hanbang.chu_xing_gao_zhao.base.BaseActivity;
import com.hanbang.cxgz_2.R;

public class DynamicSearchActivity extends BaseActivity {
	/** 动态 */
	private TextView dynamic;
	/** 厨师 */
	private TextView chef;
	/** 经理人 */
	private TextView managerPenson;
	/** 组 */
	private TextView group;
	/** 秘籍 */
	private TextView esoterica;
	/** 课程 */
	private TextView course;
	/** 资料 */
	private TextView data;
	/** 标准 */
	private TextView standard;
	/** 川菜 */
	private TextView chuanCai;
	/** 湘菜 */
	private TextView xiangCai;
	/** 粤菜 */
	private TextView yueCai;
	/** 拜师 */
	private TextView baiShi;
	/** 视频 */
	private TextView video;
	/** 教学 */
	private TextView teaching;
	/** 经理 */
	private TextView manager;
	/** 简介 */
	private TextView brief;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.dynamic_search);
		initView();
		setOnClickListener();
	}

	/**
	 * 初始化view
	 */
	private void initView() {
		dynamic = (TextView) findViewById(R.id.dynamic_sarech_dynamic);
		chef = (TextView) findViewById(R.id.dynamic_sarech_chef);
		managerPenson = (TextView) findViewById(R.id.dynamic_sarech_managerPerson);
		group = (TextView) findViewById(R.id.dynamic_sarech_group);
		esoterica = (TextView) findViewById(R.id.dynamic_sarech_esoterica);
		course = (TextView) findViewById(R.id.dynamic_sarech_course);
		data = (TextView) findViewById(R.id.dynamic_sarech_data);
		standard = (TextView) findViewById(R.id.dynamic_sarech_standard);
		chuanCai = (TextView) findViewById(R.id.dynamic_sarech_chuan);
		xiangCai = (TextView) findViewById(R.id.dynamic_sarech_xiang);
		yueCai = (TextView) findViewById(R.id.dynamic_sarech_yue);
		baiShi = (TextView) findViewById(R.id.dynamic_sarech_bai);
		video = (TextView) findViewById(R.id.dynamic_sarech_video);
		teaching = (TextView) findViewById(R.id.dynamic_sarech_teaching);
		manager = (TextView) findViewById(R.id.dynamic_sarech_manager);
		brief = (TextView) findViewById(R.id.dynamic_sarech_brief);

	}

	/**
	 * 设置点击事件
	 */
	private void setOnClickListener() {
		dynamic.setOnClickListener(onClickListener);
		chef.setOnClickListener(onClickListener);
		managerPenson.setOnClickListener(onClickListener);
		group.setOnClickListener(onClickListener);
		esoterica.setOnClickListener(onClickListener);
		course.setOnClickListener(onClickListener);
		data.setOnClickListener(onClickListener);
		standard.setOnClickListener(onClickListener);
		chuanCai.setOnClickListener(onClickListener);
		xiangCai.setOnClickListener(onClickListener);
		yueCai.setOnClickListener(onClickListener);
		baiShi.setOnClickListener(onClickListener);
		video.setOnClickListener(onClickListener);
		teaching.setOnClickListener(onClickListener);
		manager.setOnClickListener(onClickListener);
		brief.setOnClickListener(onClickListener);

	}

	/**
	 * 处理监听
	 */
	@SuppressWarnings("unused")
	private OnClickListener onClickListener = new OnClickListener() {
		
		@Override
		public void onClick(View v) {
			changeColor((TextView)v);
			
//			switch (v.getId()) {
//
//			case R.id.dynamic_sarech_dynamic:
//				changeColor(dynamic);
//				break;
//			case R.id.dynamic_sarech_chef:
//				changeColor(chef);
//				break;
//			case R.id.dynamic_sarech_managerPerson:
//				changeColor(managerPenson);
//				break;
//			case R.id.dynamic_sarech_group:
//				changeColor(group);
//				break;
//			case R.id.dynamic_sarech_esoterica:
//				changeColor(esoterica);
//				break;
//			case R.id.dynamic_sarech_course:
//				changeColor(course);
//				break;
//			case R.id.dynamic_sarech_data:
//				changeColor(data);
//				break;
//			case R.id.dynamic_sarech_standard:
//				changeColor(standard);
//				break;
//			case R.id.dynamic_sarech_chuan:
//				changeColor(chuanCai);
//				break;
//			case R.id.dynamic_sarech_xiang:
//				changeColor(xiangCai);
//				break;
//			case R.id.dynamic_sarech_yue:
//				changeColor(yueCai);
//				break;
//			case R.id.dynamic_sarech_bai:
//				changeColor(baiShi);
//				break;
//			case R.id.dynamic_sarech_video:
//				changeColor(video);
//				break;
//			case R.id.dynamic_sarech_teaching:
//				changeColor(teaching);
//				break;
//			case R.id.dynamic_sarech_manager:
//				changeColor(manager);
//				break;
//			case R.id.dynamic_sarech_brief:
//				changeColor(brief);
//				break;
//			default:
//				break;
//			}

		}

	};

	/**
	 * 更改textView 的字体与背景颜色
	 * 
	 * @param text
	 */
	private void changeColor(TextView text) {
		if (text.getCurrentTextColor() == 0xFFffffff) {
			text.setBackgroundResource(R.drawable.bg_solid_yellow_corners10);
			text.setTextColor(0xff000000);
		} else {

			text.setBackgroundResource(R.drawable.bg_solid_gray_corners10);
			text.setTextColor(0xFFffffff);
		}

	}

	@Override
	protected void onResume() {
		setBackArrows(findViewById(R.id.dynamic_search_back));
		super.onResume();
	}

	@Override
	protected void onPause() {
		// TODO Auto-generated method stub
		super.onPause();
	}

	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
	}

}
